﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class ReStartUI : IUIBase
{
    private Button btnReStart;

    private Text txtResult;

    public ReStartUI() : base("UI/ResultUI")
    {
        btnReStart = gameObjUI.GetComponent<Button>("BtnReStart");
        btnReStart.onClick.AddListener(OnClickReStart);

        txtResult = gameObjUI.GetComponent<Text>("TxtResult");
    }

    public void SetResult(bool success)
    {
        if (success)
        {
            txtResult.text = "战斗结果：胜利！";
        }
        else
        {
            txtResult.text = "战斗结果：失败！";
        }

        StageManager.GetInstance().RemoveCurrentStage();

        Show();
    }

    public void OnClickReStart()
    {
        // 隐藏当前UI，开始游戏
        Hide();

        StageManager.GetInstance().Start();
    }
    
}
